class RecentCounter {

    Queue<Integer> queue;

    public RecentCounter() {
        queue = new ArrayDeque<>();
    }
    
    public int ping(int t) {
        if(queue.size() == 0) {
            queue.add(t);
            return 1;
        }
        queue.add(t);
        int min = t - 3000;
        while(queue.size() != 0) {
            if(queue.peek() < min) {
                queue.poll();
                continue;
            }
            break;
        }
        return queue.size();
    }
}

/**
 * Your RecentCounter object will be instantiated and called as such:
 * RecentCounter obj = new RecentCounter();
 * int param_1 = obj.ping(t);
 */ 